package com.example.tabletexample;

import android.app.Fragment;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

public class TextFragment extends Fragment{

	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {
		//Inflate the layout
		View layout = inflater.inflate(R.layout.text_fragment, null);
		
		//setup buttons and other views here
		TextView text = (TextView) layout.findViewById(R.id.text_fragment_textview);
		
		Bundle arguments = getArguments();
		
		//if arguments is null,
		//then there are no arguments,
		//check to see if there are any
		//arguments to avoid a NullPointerException
		//when calling arguments.containsKey
		if(arguments != null){
			if(arguments.containsKey("text")){
				text.setText(arguments.getString("text"));
			}else{
				//There is no "text" argument
				text.setText("No text availible");
			}
		}else{
			//There were no arguments
			text.setText("No text availible");
		}
		
		return layout;
	}
	
}
